<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>添加平台</title>
        <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
        <link rel="stylesheet" href="css/addPlatform.css">
        <script src="./js/cookie.js"></script>
        <script src="http://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
    </head>
    <body>
        <div id="box">
            <header>添加平台</header>
            <div class="contents">
                <div class="detailInfo">
                    <table>
                        <tr>
                            <td>
                                <span>公司名称</span>
                                <input type="text" v-model.trim="input1" style="margin-top:20px;"/>
                            </td>
                            <td style="display:none;">
                                <span class="secondSpan"></span>
                                <input type="text" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>商户号</span>
                                <input type="text" disabled="disabled"/>
                            </td>
                            <td>
                                <span class="secondSpan">收款方全称</span>
                                <input type="text" v-model.trim="input2"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>创建时间</span>
                                <input type="text" disabled="disabled"/>
                            </td>
                            <td>
                                <span class="secondSpan">开户银行</span>
                                <input type="text" v-model.trim="input6"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>联系人</span>
                                <input type="text" v-model.trim="input7"/>
                            </td>
                            <td>
                                <span class="secondSpan">银行账号</span>
                                <input type="text" v-model.trim="input8"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>联系电话</span>
                                <input type="text" v-model.trim="input9"/>
                            </td>
                            <td>
                                <span class="secondSpan">业务对接人</span>
                                <input type="text" v-model.trim="input13"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>结算比率</span>
                                <input type="text" v-model.trim="input10"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="line1"></div>
                            </td>
                            <td>
                                <div class="line2"></div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>登录账号</span>
                                <input type="text" v-model.trim="input11"/>
                            </td>
                            <td>
                                <span class="secondSpan">登录密码</span>
                                <input type="text" v-model.trim="input12"/>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <footer>
                <button class="ensure" @click="ensure">确认添加</button>
                <button class="cancel" @click="cancel">取消关闭</button>
            </footer>
        </div>
    </body>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue-resource@1.3.5"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script>
        var vm = new Vue({
            el: '#box',
            data: {
                //getIp1: 'http://192.168.0.180:8085/CARSERV', //测试环境ip
                //getIp1: 'http://carnt.carnettong.com:8088/CARSERV', //正式环境ip
                getIp1: 'http://121.40.78.200:88/CARSERV',
                input1: '', //公司名称
                input2: '', //收款方全称
                input6: '', //开户银行
                input7: '', //联系人
                input8: '', //银行账号
                input9: '', //联系电话
                input10: '', //结算比率
                input11: '', //登录账号
                input12: '', //登录密码
                input13: '', //业务对接人
                once:true,//防止重复提交
            },
            created: function () {

            },
            computed: {

            },
            methods: {
                //确认添加
                ensure() {
                    if (this.input1 == '') {
                        this.$alert('公司名称不能为空!', '提示');
                        return;
                    }
                    if (this.input2 == '') {
                        this.$alert('收款方全称不能为空!', '提示');
                        return;
                    }
                    if (this.input6 == '') {
                        this.$alert('开户银行不能为空!', '提示');
                        return;
                    }
                    if (this.input7 == '') {
                        this.$alert('联系人不能为空!', '提示');
                        return;
                    }
                    if (this.input8 == '') {
                        this.$alert('银行账号不能为空!', '提示');
                        return;
                    }
                    if (this.input9 == '') {
                        this.$alert('联系电话不能为空!', '提示');
                        return;
                    }
                    if (this.input13 == '') {
                        this.$alert('业务对接人不能为空!', '提示');
                        return;
                    }
                    if (this.input10 == '') {
                        this.$alert('结算比率不能为空!', '提示');
                        return;
                    }
                    if (this.input11 == '') {
                        this.$alert('登录账号不能为空!', '提示');
                        return;
                    }
                    if (this.input12 == '') {
                        this.$alert('登录密码不能为空!', '提示');
                        return;
                    }
                    //结算率的简单验证
                    if(parseFloat(this.input10)>=1||parseFloat(this.input10)<0||parseFloat(this.input10) != parseFloat(this.input10)){
                        this.$alert('结算率为0-1的小数!', '提示');
                        return;
                    }
                    let obj = {};
                    obj.COMPNAME = this.input1;
                    obj.BANKPAYEE = this.input2;
                    obj.BANKNAME = this.input6;
                    obj.CONTACT = this.input7;
                    obj.BANKACCOUNT = this.input8;
                    obj.PHONE = this.input9;
                    obj.RATIO = this.input10;
                    obj.LOGINNAME = this.input11;
                    obj.LOGINPWD = this.input12;
                    obj.CARNTCONTACT = this.input13;
                    if(this.once){
                        this.once = false;
                        //添加平台
                        this.$http.post(this.getIp1 + '/PlatformUser/savePlatformUser.action', obj, {emulateJSON: true}).then(
                                res => {
                                    if (res.body.STATUC_CODE == 1) {
                                        this.$alert('添加成功!', '提示',{
                                            showClose:false,
                                            showConfirmButton:false
                                        });
                                        setTimeout(function(){location.href="./cooperationPlat.html"},1000);
                                    }

                                }, err => console.log(err)
                        );
                    }
                },
                //取消关闭
                cancel() {
                    history.back();
                },
            },
            filters: {

            },
        });
    </script>
</html>
